package edu.cuit.zhuyimeng.gateway.property;

import com.alibaba.nacos.api.PropertyKeyConst;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Properties;

@Component
@Data
public class ServerInfoProperties {

    @Value("spring.cloud.nacos.server-addr")
    private String serverAddr;

    @Value("spring.cloud.nacos.config.namespace")
    private String namespace;

    @Value("spring.cloud.nacos.discovery.cluster-name")
    private String clusterName;

    @Value("spring.cloud.nacos.discovery.service")
    private String service;

    @Value("spring.cloud.nacos.discovery.username")
    private String username;

    @Value("spring.cloud.nacos.discovery.password")
    private String password;

    @Value("spring.cloud.nacos.config.timeout")
    private String timeout;

    public Properties getProperties() {
        Properties properties = new Properties();

        properties.put(PropertyKeyConst.SERVER_ADDR, getServerAddr());
        properties.put(PropertyKeyConst.NAMESPACE, getNamespace());
        properties.put(PropertyKeyConst.USERNAME, getUsername());
        properties.put(PropertyKeyConst.PASSWORD, getPassword());
        properties.put(PropertyKeyConst.CLUSTER_NAME, getClusterName());

        return properties;
    }
}
